package com.dlc.felear.xiaoensale.helper;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolExecutorHelper {
    private static ThreadPoolExecutorHelper instance;
    private ThreadPoolExecutor scheduledThreadPool;
    private ThreadPoolExecutorHelper() {
        scheduledThreadPool = new ThreadPoolExecutor(2, 15, 60, TimeUnit.SECONDS,
                new LinkedBlockingQueue<Runnable>(250));
    }

    public static ThreadPoolExecutorHelper getInstance() {
        if(instance==null){
          synchronized (ThreadPoolExecutorHelper.class){
              if(instance==null){
                 instance=new ThreadPoolExecutorHelper();
              }
          }
        }
        return instance;
    }

    public ThreadPoolExecutor getScheduledThreadPool(){
        return scheduledThreadPool;
    }
}
